<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
    <meta charset="utf-8">
    <title>牛皮</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <!-- 引入框架的js、css等 -->
    <jsp:include page="${request.contextPath}/static/include.jsp" flush="true" />

    <script type="text/html" id="isFreeze">
        {{#  if(d.isFreeze == 0){ }}
            否
        {{#  } else if(d.isFreeze == 1) { }}
            是
        {{#  } }}
    </script>

    <script type="text/html" id="tableBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
    </script>
    <script type="text/javascript">
        layui.use([ 'form', 'layer', 'table', 'laydate', 'tree', 'util'], function(){
            var layer = parent.layer === undefined ? layui.layer : top.layer
                ,$ = layui.jquery
                ,laydate = layui.laydate
                ,table = layui.table
                ,tree = layui.tree
                ,layer = layui.layer
                ,util = layui.util;

        table.render({
            elem : '#_table'
            ,url : __ctxPath + '/framework/SysUser.do?method=list'
            ,cellMinWidth : 120 			//全局定义所有常规单元格的最小宽度（默认：60），一般用于列宽自动分配的情况。其优先级低于表头参数中的 minWidth
            ,page : true 					//开启分页（默认：false）
            ,height : "full-75" 			//设定容器高度
            ,limits : [ 10, 15, 20, 25 ] 	//每页条数的选择项，默认：[10,20,30,40,50,60,70,80,90]。优先级低于 page 参数中的 limits 参数。
            ,limit : 15 					//每页显示的条数（默认：10）。值务必对应 limits 参数的选项。优先级低于 page 参数中的 limit 参数。
            ,toolbar: '#_leftTableToolbar'		//开启工具栏（动态列素筛选、导出、打印）
            ,loading: true 					//开启加载效果（默认false）
            ,id : "_table"
            ,request: {
                pageName: 'page', //页码的参数名称，默认：page
                limitName: 'rows' //每页数据量的参数名，默认：limit
            }
            ,cols : [ [
                {
                    field : "lid"
                    ,hide : true
                }, {
                    field : "cname"
                    ,title : "昵称"
                    ,align : "left"
                    ,sort : true
                }, {
                    field : "account"
                    ,title : "登录账号"
                    ,align : "left",
                    sort : true
                }, {
                    field : "roleNames"
                    ,title : "角色"
                    ,align : "left"
                    ,sort : true
                }, {
                    field : 'isFreeze'
                    ,title : '账号是否冻结'
                    ,sort : true
                    ,align : 'center'
                    ,templet : "#isFreeze"
                }, {
                    field : "operatorName"
                    ,title : "操作人"
                    ,align : "center"
                    ,sort : true
                    ,hide : true
                }, {
                    title : '操作'
                    ,templet : '#tableBar'
                    ,fixed : "right"
                    ,align : "center"
                }
            ] ]
            ,done : function(res, curr, count){
                /*$("#toAdd").click(function(){
                    toPage('system/sysUser/jsp/add', {width:'40%', height:'60%', title:'新增'})
                });*/
            }
        });

        //监听table行内编辑按钮
        table.on('tool(_table)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var layEvent = obj.event,
                data = obj.data;

            if (layEvent === 'edit') { //修改
                toPage("/framework/SysUser.do?method=toEditOrDetail", {lid: data.lid, pageType: TO_EDIT, pageUrl: "system/sysUser/jsp/update.jsp", width:'40%', height:'60%'});
            } else if (layEvent === 'del') { //删除
                if(1 == data.lid){
                    return layer.alert("不能删除用户管理员");
                }
                layer.confirm('确定删除该记录？', {icon : 3, title : '提示信息'}, function(index) {
                    $.post(__ctxPath+"/framework/SysUser.do?method=delete", {lid: data.lid}, function(response){
                        layer.close(index);
                        if(response.msg) layer.msg(response.msg);
                        if(response.code == RESPONSE_SUCCESS){
                            reloadTable();
                        }
                    });
                });
            }
        });

        //查询刷新
        $(".search_btn").click(function(){
            table.reload('_table', {
                where : serializeObject($("#_form"))
            });
        });

    });
    </script>
</head>
<body>
        <!-- 查询条件 -->
        <form class="layui-form" id="_form" action="">
            <div class="layui-inline">
                <label class="layui-form-label">用户姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="where_su.cname_like" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">登录账号</label>
                <div class="layui-input-inline">
                    <input type="text" name="where_su.account_LK" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">角色名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="where_sr.cname_LK" class="layui-input">
                </div>
            </div>
            <button type="button" class="layui-btn layui-icon search_btn custom" style="margin-left: 30px;padding: 0 10px;">&#xe615;&nbsp;查询</button>
            <button type="button" class="layui-btn layui-icon layui-btn-primary reset_btn custom" style="margin-left:5px;padding: 0 10px;">&#xe669;&nbsp;重置</button>
        </form>

        <div class="layui-row">
            <!-- 内容主体区域 -->
            <div class="layui-col-md12">
                <script type="text/html" id="_leftTableToolbar">
                    <div class="table-tool-btn">
                        <button type="button" class="layui-btn layui-icon-add-1 layui-icon" id="toAdd"
                            onclick="toPage('system/sysUser/jsp/add.jsp', {pageType: TO_ADD, width:'40%', height:'60%', title:'新增（温馨提示：新建的用户密码默认为123456）'});">新增用户</button>
                    </div>
                </script>
                <table id="_table" lay-filter="_table"></table>
            </div>
        </div>
</body>
</html>
